﻿using MiniFox.Platform;
using MiniFox.Resources;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.ComponentModel.DataAnnotations;

namespace Sys.Core.Models.Dto
{
    public class UserDto
    {
        [Key]
        [JsonProperty("userId")]
        [Editable(false)]
        [StringLength(64, ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonStringLength")]
        public string? UserID { get; set; }

        [JsonProperty("loginName")]
        [Required(ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonRequired")]
        [RegularExpression(GlobalKey.REGEX_SECURE_LOGINNAME, ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonUnmatchRegex")]
        public string LoginName { get; set; }

        [JsonProperty("displayName")]
        [Required(ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonRequired")]
        public string DisplayName { get; set; }

        [JsonProperty("secEmail")]
        [Required(ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonRequired")]
        [RegularExpression(GlobalKey.REGEX_SECURE_EMAILADDRESS, ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonUnmatchRegex")]
        public string SecEmail { get; set; }

        [JsonProperty("cellphone")]
        [Required(ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonRequired")]
        [RegularExpression(GlobalKey.REGEX_SECURE_CELLPHONE, ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonUnmatchRegex")]
        public virtual string Cellphone { get; set; }

        [JsonProperty("userStatus")]
        [Required(ErrorMessageResourceType = typeof(CommonMessages), ErrorMessageResourceName = "MSG_CommonRequired")]
        [JsonConverter(typeof(StringEnumConverter))]
        public IdentityStatus UserStatus { get; set; }
    }
}
